﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AdaptiveDeNet.Functions
{
    public class Dejong2 : Function
    {
        #region Function Members

        public double Feval(double[] x)
        {
            double ret = 0;

            for (int i = 0; i < x.Length - 1; i++)
            {
                //Xi^2 - Xi+1
                double xi1 = x[i] * x[i] - x[i + 1]; 
                //1 - Xi
                double xi2 = 1 - x[i];

                ret += 100 * (xi1 * xi1) + (xi2 * xi2);
            }

            return ret;
        }

        #endregion

        #region Function Members


        public Function GetInstance()
        {
            Function _this = new Dejong2();

            return _this;
        }

        #endregion

    }
}
